/* PacketStream - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */

public class PacketStream extends Stream {
	public ISAAC aClass61_2141;
	public static JString aClass3_2142 = Class39_Sub5_Sub9.createJString(124, "glow1:");
	public static JString aClass3_2143 = Class39_Sub5_Sub9.createJString(123, "bevor Sie den Vorgang wiederholen)3");
	public static JString aClass3_2144;
	public int bitPosition;
	public static PacketStream outputStream;
	public static JString aClass3_2147;
	public static TextRenderer aClass39_Sub5_Sub10_Sub1_2148;
	public static JString aClass3_2149 = Class39_Sub5_Sub9.createJString(120, "redstone3");
	public static int[] anIntArray2150 = new int[50];
	public static JString aClass3_2151;
	public static JString aClass3_2152;
	public static boolean aBoolean2153;
	public static JString aClass3_2154;
	public static Class57 aClass57_2155;
	public static int anInt2156;
	public static int anInt2157;
	public static Class7 aClass7_2158;
	public static int anInt2159;

	public int availableBits(int i, int i_0_) {
		return -bitPosition + i_0_ * 8;
	}

	public void initBitAccess() {
		bitPosition = currentOffset * 8;
	}

	public void initializeISAAC(int[] keys, int i) {
		aClass61_2141 = new ISAAC(keys);
	}

	public void finishBitAccess() {
		currentOffset = (bitPosition + 7) / 8;
	}

	public PacketStream(int i) {
		super(i);
	}

	public static void method839(boolean bool) {
		aClass39_Sub5_Sub10_Sub1_2148 = null;
		aClass3_2154 = null;
		aClass57_2155 = null;
		anIntArray2150 = null;
		aClass3_2152 = null;
		outputStream = null;
		aClass3_2142 = null;
		aClass7_2158 = null;
		aClass3_2147 = null;
		aClass3_2143 = null;
		aClass3_2151 = null;
		aClass3_2144 = null;
		aClass3_2149 = null;
	}

	public static void method840() {
		Class2.aClass7_54.method134(27392);
	}

	public static Class39_Sub5_Sub10_Sub3 method841(int i, int i_1_, boolean bool, int i_2_, int i_3_, int i_4_) {
		long l = ((long) i - -((long) i_2_ << 16) + ((long) i_4_ << 38) + ((long) i_1_ << 40));
		if (!bool) {
			Class39_Sub5_Sub10_Sub3 class39_sub5_sub10_sub3 = ((Class39_Sub5_Sub10_Sub3) Class39_Sub5_Sub1.aClass7_1663.method133((byte) -86, l));
			if (class39_sub5_sub10_sub3 != null)
				return class39_sub5_sub10_sub3;
		}
		Class39_Sub5_Sub1 class39_sub5_sub1 = Class26.method291(-94, i);
		if (i_2_ > 1 && class39_sub5_sub1.anIntArray1670 != null) {
			int i_5_ = -1;
			for (int i_6_ = 0; i_6_ < 10; i_6_++) {
				if (class39_sub5_sub1.anIntArray1646[i_6_] <= i_2_ && class39_sub5_sub1.anIntArray1646[i_6_] != 0)
					i_5_ = class39_sub5_sub1.anIntArray1670[i_6_];
			}
			if (i_5_ != -1)
				class39_sub5_sub1 = Class26.method291(-104, i_5_);
		}
		Model class39_sub5_sub4_sub6 = class39_sub5_sub1.method468(1, true, (byte) -114);
		if (class39_sub5_sub4_sub6 == null)
			return null;
		Class39_Sub5_Sub10_Sub3 class39_sub5_sub10_sub3 = null;
		if (class39_sub5_sub1.anInt1644 != -1) {
			class39_sub5_sub10_sub3 = method841(class39_sub5_sub1.anInt1651, 0, true, 10, 84, 1);
			if (class39_sub5_sub10_sub3 == null)
				return null;
		}
		int[] is = Class39_Sub5_Sub10.anIntArray1818;
		int i_7_ = Class39_Sub5_Sub10.anInt1821;
		int i_8_ = Class39_Sub5_Sub10.anInt1822;
		int i_9_ = Class39_Sub5_Sub10.anInt1823;
		int i_10_ = Class39_Sub5_Sub10.anInt1824;
		int i_11_ = Class39_Sub5_Sub10.anInt1820;
		int i_12_ = Class39_Sub5_Sub10.anInt1819;
		int[] is_13_ = Rasterizer.method661();
		int i_14_ = Rasterizer.anInt2461;
		int i_15_ = Rasterizer.anInt2463;
		Class39_Sub5_Sub10_Sub3 class39_sub5_sub10_sub3_16_ = new Class39_Sub5_Sub10_Sub3(36, 32);
		Class39_Sub5_Sub10.method610(class39_sub5_sub10_sub3_16_.anIntArray2476, 36, 32);
		Class39_Sub5_Sub16.anIntArray1977 = Rasterizer.method657(Class39_Sub5_Sub16.anIntArray1977);
		Class39_Sub5_Sub10.method611(0, 0, 36, 32, 0);
		Rasterizer.aBoolean2471 = false;
		Rasterizer.method659(16, 16);
		int i_17_ = class39_sub5_sub1.anInt1649;
		if (!bool) {
			if (i_4_ == 2)
				i_17_ *= 1.04;
		} else
			i_17_ *= 1.5;
		int i_18_ = ((Rasterizer.anIntArray2456[class39_sub5_sub1.anInt1669]) * i_17_ >> 16);
		int i_19_ = ((Rasterizer.anIntArray2469[class39_sub5_sub1.anInt1669]) * i_17_ >> 16);
		class39_sub5_sub4_sub6.method542();
		class39_sub5_sub4_sub6.method549(0, class39_sub5_sub1.anInt1676, class39_sub5_sub1.anInt1656, class39_sub5_sub1.anInt1669, class39_sub5_sub1.anInt1674, (i_19_ + (class39_sub5_sub4_sub6.anInt1726 / 2) + class39_sub5_sub1.anInt1654), class39_sub5_sub1.anInt1654 + i_18_);
		if (i_4_ >= 1)
			class39_sub5_sub10_sub3_16_.method683(1);
		if (i_4_ >= 2)
			class39_sub5_sub10_sub3_16_.method683(16777215);
		if (i_1_ != 0)
			class39_sub5_sub10_sub3_16_.method672(i_1_);
		Class39_Sub5_Sub10.method610(class39_sub5_sub10_sub3_16_.anIntArray2476, 36, 32);
		if (class39_sub5_sub1.anInt1644 != -1)
			class39_sub5_sub10_sub3.method670(0, 0);
		if (!bool && (class39_sub5_sub1.anInt1662 == 1 || i_2_ != 1) && i_2_ != -1) {
			aClass39_Sub5_Sub10_Sub1_2148.method647(Class44.method911(i_2_, (byte) 93), 1, 10, 1);
			aClass39_Sub5_Sub10_Sub1_2148.method647(Class44.method911(i_2_, (byte) 75), 0, 9, 16776960);
		}
		if (!bool)
			Class39_Sub5_Sub1.aClass7_1663.method135(class39_sub5_sub10_sub3_16_, l, (byte) 120);
		Class39_Sub5_Sub10.method610(is, i_7_, i_8_);
		Class39_Sub5_Sub10.method619(i_10_, i_11_, i_9_, i_12_);
		Rasterizer.method657(is_13_);
		Rasterizer.anInt2463 = i_15_;
		Rasterizer.anInt2461 = i_14_;
		Rasterizer.method654();
		Rasterizer.aBoolean2471 = true;
		return class39_sub5_sub10_sub3_16_;
	}

	public void writePacket(int i_20_) {
		buffer[currentOffset++] = (byte) (i_20_ + 0);//aClass61_2141.method1039((byte) 125));
	}

	public int readBits(int numBits) {
		int i_22_ = bitPosition >> 3;
		int i_23_ = 8 - (bitPosition & 0x7);
		bitPosition += numBits;
		int i_24_ = 0;
		for (/**/; numBits > i_23_; i_23_ = 8) {
			i_24_ += (Class39_Sub5_Sub9.anIntArray1804[i_23_] & buffer[i_22_++]) << -i_23_ + numBits;
			numBits -= i_23_;
		}
		if (i_23_ != numBits)
			i_24_ += (buffer[i_22_] >> -numBits + i_23_ & Class39_Sub5_Sub9.anIntArray1804[numBits]);
		else
			i_24_ += (buffer[i_22_] & Class39_Sub5_Sub9.anIntArray1804[i_23_]);
		return i_24_;
	}

	public int readPacket() {
		return ((buffer[currentOffset++] - 0) & 0xff);//aClass61_2141.method1039((byte) 126)) & 0xff);
	}

	static {
		aClass3_2147 = Class39_Sub5_Sub9.createJString(124, "@lre@");
		aClass3_2152 = Class39_Sub5_Sub9.createJString(116, "Spiel)2Engine wird gestartet)3)3)3");
		aClass3_2154 = Class39_Sub5_Sub9.createJString(109, "b12_full");
		anInt2157 = 0;
		aClass3_2151 = Class39_Sub5_Sub9.createJString(122, "null");
		aClass3_2144 = aClass3_2142;
		outputStream = new PacketStream(5000);
		aClass7_2158 = new Class7(64);
		anInt2159 = 0;
	}
}
